package com.lihao.sam.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lihao.sam.dao.MaintainExamineDao;
import com.lihao.sam.entity.MaintainExamine;
import com.lihao.sam.service.intf.MaintainExamineService;
import com.lihao.sam.vo.PageVo;
import com.lihao.sam.vo.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author Qinheyun
 * @Description:TODO
 */
@Service
public class MaintainExamineServiceImpl implements MaintainExamineService {
    @Resource
    private MaintainExamineDao dao;
    @Override
    public R add(MaintainExamine maintainExamine) {
        if(dao.add(maintainExamine)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R update(MaintainExamine maintainExamine) {
        if(dao.update(maintainExamine)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R del(int id) {
        if(dao.del(id)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public PageVo all(String inspectName,int page,int limit) {
        PageHelper.startPage(page, limit);
        PageInfo<MaintainExamine> pageInfo=new PageInfo<>(dao.all(inspectName));
        return PageVo.ok(pageInfo.getTotal(),pageInfo.getList());
    }
}
